package com.springbootmybatis.service.impl;

import com.springbootmybatis.dao.DailyPlanDao;
import com.springbootmybatis.dao.DailyPlanDetailDao;
import com.springbootmybatis.entity.DailyPlan;
import com.springbootmybatis.entity.DailyPlanDetail;
import com.springbootmybatis.service.DailyPlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DailyPlanServiceImpl implements DailyPlanService {

    @Resource
    DailyPlanDao dailyPlanDao;
    @Resource
    DailyPlanDetailDao dailyPlanDetailDao;
    @Override
    public void addDailyPlan(DailyPlan dailyPlan) {
        dailyPlanDao.insert(dailyPlan);
    }

    @Override
    public void updateDailyPlan(DailyPlan dailyPlan) {
        dailyPlanDao.update(dailyPlan);
    }

    @Override
    public DailyPlan getDailyPlanById(Long id) {
        return dailyPlanDao.getDailyPlanById(id);
    }

    @Override
    public List<DailyPlan> getDailyPlanList(Long current, Long size) {
        return dailyPlanDao.getDailyPlanList(current, size);
    }

    @Override
    public void deleteDailyPlanById(Long id) {
        dailyPlanDao.deleteById(id);
    }

    @Override
    public void updateDailyPlanDetail(DailyPlanDetail dailyPlanDetail) {
        dailyPlanDetailDao.update(dailyPlanDetail);
    }

    @Override
    public void deleteDailyPlanDetailById(Long id) {
        dailyPlanDetailDao.delete(id);
    }

    @Override
    public void addDailyPlanDetail(List<DailyPlanDetail> list) {
        dailyPlanDetailDao.insert(list);
    }

    @Override
    public List<DailyPlanDetail> getDailyPlanDetailByDailyPlanId(Long dailyPlanId) {
        return dailyPlanDetailDao.getByDailyPlanId(dailyPlanId);
    }
}
